/*
 * @Author: your name
 * @Date: 2021-10-16 22:28:25
 * @LastEditTime: 2021-10-16 22:32:18
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\模板问题\P1510 精卫填海\mingcode1.cpp
 */
#include <iostream>
#include<algorithm>
#include <cstring>
using namespace std;
//f(i, j)表示前i块石头，总体积大于等于j所划分的最小体力值
const int N = 10010;
int m, n, c;
//f[i][j] 前i个石头 体积>=j 需要的最小体力值
int f[N][N];

int main(void)
{
    //需要的总空间m 石头数目n 剩余体力c 
    cin >> m >> n >> c;
    memset(f, 0x7f, sizeof f);
    f[0][0] = 0;
    for(int i = 1; i <= n; i++)
    {
        //体积 体力
        int v, w;
        cin >> v >> w;
        for(int j = 0; j <= m; j++)
        {
            f[i][j] = min(f[i][j], f[i - 1][max(0, j - v)] + w);
        }
    }

    if(f[n][m] <= c)
        cout << c - f[n][m] << endl;
    else
        puts("impossible");
    return 0;
}
